// Nick Nissen, Mads Jakobsen og Jesper Larsen
package hc.andersen.paraden;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Mads
 * Date: 24-05-12
 * Time: 14:22
 * To change this template use File | Settings | File Templates.
 */
public class MenuActivity extends Activity {



    @Override
    public void onCreate(Bundle savedInstanceState) {



        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        if(DataHelper.getDialog() != null && DataHelper.getDialog().isShowing())
            DataHelper.getDialog().dismiss();


        Button NasteBookingKnap = (Button)findViewById(R.id.nastbook);
        Button MinNasteBookingKnap = (Button)findViewById(R.id.minnastbook);
        Button MinProfilKnap = (Button)findViewById(R.id.minprofil);
        Button SogSpillerKnap = (Button)findViewById(R.id.sogprofil);
        Button FindTeksterKnap = (Button)findViewById(R.id.findtekster);

        NasteBookingKnap.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               GaaTilBooking(view);
            }
        });

        MinNasteBookingKnap.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                GaaTilMinBooking(view);
            }
        });

        MinProfilKnap.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                GaaTilMinProfil(view);
            }
        });

        SogSpillerKnap.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                GaaTilSogSpiller(view);
            }
        });

        FindTeksterKnap.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                GaaTilSogTekster(view);
            }
        });


    }

    /*
    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.men, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        switch(item.getItemId())
        {
            case R.id.Logud:
                    super.finish();
                break;

            default:
                break;
        }
        return true;
    }

      */

    public void GaaTilBooking(View v){
        try{

           DataHelper.setDialog(ProgressDialog.show(this, "",
                   "Loading. Please wait...", true));

        Intent bookingsiden = new Intent(this,NextBookingActivity.class);
        this.startActivity(bookingsiden);
        }
        catch(Exception e)
        {
            Toast fejlbesked = Toast.makeText(this, "Siden kan ikke åbnes i øjeblikket", Toast.LENGTH_SHORT);
            fejlbesked.show();
        }
    }

    public void GaaTilMinBooking(View v){
      try{
          DataHelper.setDialog(ProgressDialog.show(this, "",
                  "Loading. Please wait...", true));

        Intent minbookingsiden = new Intent(this,MinNextBookingActivity.class);
        this.startActivity(minbookingsiden);
        }
        catch(Exception e)
        {
            Toast fejlbesked = Toast.makeText(this, "Siden kan ikke åbnes i øjeblikket", Toast.LENGTH_SHORT);
            fejlbesked.show();
        }
    }

    public void GaaTilMinProfil(View v){
      try{

          DataHelper.setDialog(ProgressDialog.show(this, "",
                  "Loading. Please wait...", true));

          Map<String,String> userData = DataHelper.HentBrugerData(getBaseContext());
          String id = userData.get("id");
          Bundle bundle = new Bundle();
          bundle.putString("id",id);
        Intent minprofilsiden = new Intent(this,ProfileActivity.class);
          minprofilsiden.putExtras(bundle);
        this.startActivity(minprofilsiden);
      }
      catch(Exception e)
      {
          Toast fejlbesked = Toast.makeText(this, "Siden kan ikke åbnes i øjeblikket", Toast.LENGTH_SHORT);
          fejlbesked.show();
      }
    }

    public void GaaTilSogSpiller(View v){
      try{
          DataHelper.setDialog(ProgressDialog.show(this, "",
                  "Loading. Please wait...", true));

          Bundle bundle = new Bundle();
          bundle.putString("sogeinfo","0");
        Intent sogspillersiden = new Intent(this,SogSpiller.class);
         sogspillersiden.putExtras(bundle);
        this.startActivity(sogspillersiden);
      }
      catch(Exception e)
      {
          Toast fejlbesked = Toast.makeText(this, "Siden kan ikke åbnes i øjeblikket", Toast.LENGTH_SHORT);
          fejlbesked.show();
      }
    }

    public void GaaTilSogTekster(View v){
       try{
        Intent sogtekstersiden = new Intent(this,MenuActivity.class);
        this.startActivity(sogtekstersiden);
       }
       catch(Exception e)
       {
           Toast fejlbesked = Toast.makeText(this, "Siden kan ikke åbnes i øjeblikket", Toast.LENGTH_SHORT);
           fejlbesked.show();
       }
    }
}
